7c7fa7
@@ -184,6 +184,7 @@
public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
           destTable.getCols());
       List<Integer> sortPositions = null;
       List<Integer> sortOrder = null;
+      ArrayList<ExprNodeDesc> bucketColumns;
       if (fsOp.getConf().getWriteType() == AcidUtils.Operation.UPDATE ||
           fsOp.getConf().getWriteType() == AcidUtils.Operation.DELETE) {
         // When doing updates and deletes we always want to sort on the rowid because the ACID
@@ -191,6 +192,7 @@
public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
         // ignore whatever comes from the table and enforce this sort order instead.
         sortPositions = Arrays.asList(0);
         sortOrder = Arrays.asList(1); // 1 means asc, could really use enum here in the thrift if
+        bucketColumns = new ArrayList<>(); // Bucketing column is already present in ROW__ID, which is specially handled in ReduceSink
       } else {
         if (!destTable.getSortCols().isEmpty()) {
           // Sort columns specified by table
@@ -202,6 +204,8 @@
public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
           sortOrder = Lists.newArrayList();
           inferSortPositions(fsParent, sortPositions, sortOrder);
         }
+        List<ColumnInfo> colInfos = fsParent.getSchema().getSignature();
+        bucketColumns = getPositionsToExprNodes(bucketPositions, colInfos);
       }
       List<Integer> sortNullOrder = new ArrayList<Integer>();
       for (int order : sortOrder) {
@@ -212,8 +216,6 @@
public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
       for (int i : sortOrder) LOG.debug("sort order " + i);
       for (int i : sortNullOrder) LOG.debug("sort null order " + i);
       List<Integer> partitionPositions = getPartitionPositions(dpCtx, fsParent.getSchema());
-      List<ColumnInfo> colInfos = fsParent.getSchema().getSignature();
-      ArrayList<ExprNodeDesc> bucketColumns = getPositionsToExprNodes(bucketPositions, colInfos);
 
       // update file sink descriptor
       fsOp.getConf().setMultiFileSpray(false);
